Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update formiojs dependency #1522

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jasonchung1871
Copy link
Collaborator

@jasonchung1871 jasonchung1871 commented Oct 22, 2024

Description

Building on the work made by @vijaivir.

This PR updates the formiojs library from version 4.14.13 to 4.21.5. The primary motivator for this upgrade is that version4.19 fixes an issue where a select list component within a data grid component isn't rendered correctly.

Walter pointed out that there is a double render bug for HTMLElement components in version 4.19, so keep an eye out for it.

Before Upgrade

select_before

After Upgrade

select_after

Issues

This upgrade also introduces an issue where the HTML component using a <p> tag renders twice. For example, using the following HTML code will render the <p> content twice.

<p style=" word-break: keep-all; min-width: 80px; text-align: center;">
  <b>Sample<br>Heading</b>
</p>

Screenshot 2024-09-05 at 2 37 35 AM
Screenshot 2024-09-05 at 2 38 14 AM

This is likely due to a bug in Formio's HTML rendering logic. A user has raised this with their team, and it's currently being worked on.

Solution 1: Use Attributes

The Formio HTML element component is meant to be used as a low-code component that provides configuration for CSS classes and attributes in its settings. Formio recommends using the 'Content' component for more complex HTML in their documentation. The first solution is to remove the <p> tag from the content field and use the attributes to define the style.

Screenshot 2024-09-05 at 3 05 18 AM
Screenshot 2024-09-05 at 3 07 33 AM

Solution 2: Use <div>

The second solution would be to use div as the HTML tag value instead of the default p. This makes it so the content is placed within a <div> tag and the content is not duplicated.

Screenshot 2024-09-05 at 3 15 39 AM

Screenshot 2024-09-05 at 3 15 16 AM

This is a faster solution, but it will remove the default margins applied to <p> tags.

Further Comments

The PR deployment can be used to test out more complex forms and ensure that the HTML content is rendering correctly. There might be similar solutions, such as using the <span> tag, depending on the use case. If the issue with the select list not rendering isn't critical, we can wait for the next version in which Formio fixes the issue, but more testing would need to be done as that would be an upgrade to version ^4.21.2.

Types of changes

build (change in build system or dependencies)

Checklist

  • I have read the CONTRIBUTING doc
  • I have checked that unit tests pass locally with my changes
  • I have run the npm script lint on the frontend and backend
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • I have approval from the product owner for the contribution in this pull request

Updates the formiojs dependency from 4.14.13 to 4.21.5
Copy link

@jasonchung1871 jasonchung1871 marked this pull request as draft October 22, 2024 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant